<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    /*if语句*/
    var age = 14;

    if (age > 18){
        alert(age + "大于18岁，成年了！");
    }else{
        alert(age + "小于18岁，未成年！");
    }


    /*switch结构*/
    var num = 3;
    switch (num) {
        case 1:
            alert("星期一");
            break;
        case 2:
            alert("星期二");
            break;
        case 3:
            alert("星期三");
            //break;
        case 4:
            alert("星期四");
            break;
        default:
            alert("输入有误！");
            break;
    }

    /*for循环*/
    var sum = 0;
    for (let i = 0;i < 10;i++){
        sum += i;
    }
    alert(sum);

    /*while循环*/
    var sum = 0;
    var num = 0;
    while (num < 10){
        sum += num;
        num++;
    }
    alert(sum);

    /*do-while*/
    var sum = 0;
    var i1 = 0;
    do {
        sum += i1;
        i1++;
    }while (i1 < 10);
    alert(sum);

</script>
</html>
